package service.impl;

import moder.Pager;
import moder.TbProduct;
import service.TbProductService;
import java.util.List;

public class TbProductServiceImpl implements TbProductService {
    dao.TbProductDao dao = new dao.impl.TbProductDaoImpl();

    // 获得热门商品
    @Override
    public List<TbProduct> findHotProductList() {
        List<TbProduct> hotProductList = null;
        try {
            hotProductList = dao.findHotProduct();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return hotProductList;
    }

    // 获得最新商品
    @Override
    public List<TbProduct> findNewProductList() {
        List<TbProduct> newProductList = null;
        try {
            newProductList = dao.findNewProduct();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return newProductList;
    }

    // 获得分页数据
    @Override
    public Pager<TbProduct> goodsPager(Integer pagesize, Integer pageindex, String cid) {
        // TODO Auto-generated method stub
        return dao.goodsPager(pagesize, pageindex, cid);
    }

    // 根据ID获得商品
    @Override
    public TbProduct getAllProduct(String pid) {
        TbProduct product = null;
        TbProduct nowProduct = dao.getAllProduct(pid);
        if (nowProduct != null) {
            product = nowProduct;
        }
        return product;
    }
    // 查找所有用户
    @Override
    public List<TbProduct> findAllProduct() {
        dao.TbProductDao dao = new dao.impl.TbProductDaoImpl();
        return dao.findAllProduct();
    }
}

